import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Random;

public class Team {
	protected Hashtable<String, Double> statIndex = new Hashtable<String, Double>();
	protected ArrayList<String> statList = new ArrayList<String>();
	
	String teamName;
	String conf;
	String div;
	Double streak = 0.0; // win/loss streak

	public Team()
	{
		
	}
	
	public void insertStat(String stat, double val){
		statIndex.put(stat, new Double(val));
		statList.add(stat);
	}

	public Enumeration<String> getListOfStats(){
		return statIndex.keys();
	}
	
	public String getRandomStat(){
		Random rand = new Random();
		
		return statList.get(rand.nextInt(statList.size()));
	}
	
	public Double getStat(String stat){
		return statIndex.get(stat);
	}
	
 	public void streak(String n)
	{
		int i=0;
		while(n.charAt(i)!='W'&&n.charAt(i)!='L')
			i++;

		streak=Double.parseDouble(n.substring(0,i));
		if(n.charAt(i)=='L')
			streak*=-1;    	
	}

	public String toString(){
		Enumeration<String> statKeys = statIndex.keys();
		Enumeration<Double> statValues = statIndex.elements();
		
		String labels = String.format("%20s %4s %4s ", "teamName", "conf", "div");
		String values = String.format("%20s %4s %4s ", teamName, conf, div);
		
		while(statKeys.hasMoreElements()){
			String curKey = statKeys.nextElement();
			String curVal = String.valueOf(statValues.nextElement());
			
			if(curKey.length() > curVal.length()){
				labels += curKey + " ";
				for(int i = 0; i < curKey.length() - curVal.length(); i ++)
					values += " ";
				values += curVal + " ";
			}
			else{
				values += curVal + " ";				
				for(int i = 0; i < curVal.length() - curKey.length(); i ++)
					labels += " ";
				labels += curKey + " ";
			}
		}
		
		return labels + "\n" + values;
	}
}